<!DOCTYPE html>
<html lang="en">

<head>
	<base th:href="${#request.getContextPath()}+'/'">
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <title>畜牧源物联平台</title>
    <meta name="keywords" content="业务系统基础平台">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="css/login-style.css" rel="stylesheet">
    <link rel="shortcut icon" href="favicon.ico">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>
</head>

<body class="signin">
<div class="main-agileits">
    <!--form-stars-here-->
    <div class="form-w3-agile">
<!--        <img alt="image" src="img/logo_3.png" style="height: 70px;width: 70px;"/>-->
        <h2 class="sub-agileits-w3layouts">畜牧源物联平台</h2>
        <form id="signupForm">
            <input type="text" id="username" name="username" placeholder="账号" required="" />
            <input type="password" id="password" name="password" placeholder="密码" required="" />
            <a href="#" class="forgot-w3layouts"></a>
            <div class="submit-w3l">
                <input type="button" id = "login-button" value="登录">
            </div>
        </form>
    </div>
</div>
<!--//form-ends-here-->
<!-- copyright -->
<div class="copyright w3-agile">
    <p> © 2022  屹淼所有</p>
</div>
<!-- //copyright -->
<script type="text/javascript" src="js/jquery-2.1.4.min.js" ></script>
<script th:inline="javascript"> var ctx = [[${#request.getContextPath()}]];</script>
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>

<script src="js/plugins/layer/layer.min.js" ></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#login-button").on('click', function () {
            login();
        });
        $("body").keydown(keyDownLogon);
    });

    function login() {
        if($('#username').val()==''){
            layer.msg('请输入您的账号');
            return;
        }
        if($('#password').val()==''){
            layer.msg('请输入您的密码');
            return;
        }
        $.ajax({
            type: "POST",
            url: ctx + "/login",
            data: $('#signupForm').serialize(),
            success: function (r) {
                if (r.code == 0) {
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    parent.location.href = ctx +'/index?from=pc';
                } else {
                    layer.msg(r.msg);
                }
            },
        });
    }

    function keyDownLogon() {
        if (event.keyCode == "13") {
            $("#login-button").trigger('click');
        }
    }

</script>
</body>
</html>
